<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
			<input type="button" value="按钮1" id="b1" onclick="fun1()" />
			<input type="button" value="按钮2" id="b2" />
			<div id="div1" ></div>
			<div id="div2" onmouseenter="fun2()"></div>
			<form action="#" method="post" id="userinfo">
				用户名：<input type="text"	id="username" placeholder="输入账号"  onfocus="foucs1()" onblur="ifusername()" />
				<br>
				密&nbsp;&nbsp;&nbsp;码：<input type="password"	id="userpwd" placeholder="密码"  onfocus="foucs2()" onblur="ifuserpwd()"/>
				<br>
				<input type="button"  id="usersubmit" value="提交" onclick="demo1()" />
			</form>
			<div id="div3" onclick="add1()" ondblclick="remo1()" >
				
			</div>
		</body>
		
		<script type="text/javascript">
				function fun1(){
					console.log('点击按钮');
				}
				document.getElementById('b2').onclick=fun1;
				document.getElementById('div1').onclick=function(){
					console.log('有了一个小目标');
				}
			function fun2(){
				console.log('进去');
			}
			function fun3(){
				console.log('出来');
			}
			document.getElementById('div2').onmouseleave=fun3;
			document.getElementById('div2').onmousemove=function (){
				console.log('我开始动了');
			}
			var name=document.getElementById('username');
			var pwd=document.getElementById('userpwd');
			function foucs1(){
				console.log('用户在输入名称');
			}
			function ifusername(){
				if (document.getElementById('username').value=='') {
					alert('没有输入用户名');
				}else{
					console.log('用户名输入成功');
				}
			}
			function foucs2(){
				console.log('用户在输入密码');
			}
			function ifuserpwd(){
				if(document.getElementById('userpwd').value==''){
					alert('没有输入密码');
				}else{
					console.log('密码输入成功');
				}
			}

			function demo1(){
				
				if(document.getElementById('username').value==''&&document.getElementById('userpwd').value==''){
					alert("用户名或密码为空");
				}else{
					console.log('输入成功');
				}
			}
			function Sthh(){
				console.log("我开始动了");
			}
			
			function add1(){
				
			document.getElementById('div3').addEventListener('mousemove',Sthh);
			}
			function remo1(){
			document.getElementById('div3').removeEventListener('mousemove',Sthh);
			}
	
	
			
		</script>
	</html>